home *** CD-ROM | disk | FTP | other *** search
- #include "iostream.h"
- #include "string.h"
-
- /*********************************************************************
-
- Laat een class member refereren aan een globale variabele, zodat
- deze 'verborgen' blijft voor de gebruiker. De globale variabele
- wordt door de library bijgehouden, de gebruiker moet deze echter
- via de de C++ shell benaderen.
-
- *********************************************************************/
-
- extern "C"
- {
- int fooint;
- char foostring[11];
- }
-
- class foo1
- {
- public:
-
- int &intReference;
- char * stringReference;
-
- foo1 (void) : intReference (fooint),
- stringReference (foostring) {} ;
- virtual ~foo1 (void) {} ;
-
- void foo (void) { cout << "Testing foo1" << endl; } ;
- };
-
- class foo2
- {
- public:
-
- int &intReference;
- char * stringReference;
-
- foo2 (void) : intReference (fooint),
- stringReference (foostring) {} ;
- virtual ~foo2 (void) {} ;
-
- void foo (void) { cout << "Testing foo2" << endl; } ;
- };
-
- void main (void)
-
- {
- foo1 *test = new foo1;
-
- fooint = 1;
- strcpy (foostring, "test");
-
- if (test)
- {
- cout << "Testing: " << test->intReference << ", "
- << test->stringReference << ".\n";
-
- test->foo ();
-
- delete test;
- }
- }
-